package editAir.buildEdit
{
	import _Pan3D.role.MeshDataManager;
	import _Pan3D.texture.TextureManager;
	
	import _me.Config;
	import _me.Scene_data;
	
	import editAir.editContent.ApplicationDomainExample;
	import editAir.editContent.FileListView;
	import editAir.editContent.ModelUiManege;
	
	import flash.display.MovieClip;
	import flash.display.StageAlign;
	import flash.display.StageDisplayState;
	import flash.display.StageScaleMode;
	import flash.display3D.Context3D;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import newPan3d.ui.UiView;

	// --------------MSN:lation_pan@live.cn  QQ: 3423526------------- //
	[SWF(backgroundColor="#FFFFFF", frameRate="60", width="1024", height="600")]
	public class buildEditView extends MovieClip
	{

		private var _sceneView:BuildEditScene3D;
		private var _fileListView:FileListView;
		


		public function buildEditView()
		{
			this.addEventListener(Event.ADDED_TO_STAGE, addToStage)
		}

		private function addToStage(evt:Event):void
		{

			ModelUiManege.stage=this.stage;
			ModelUiManege.uiSwf=new ApplicationDomainExample();
			ModelUiManege.uiSwf.baceFun=loadUIok;

		}
		public function loadUIok():void
		{
			addView();
		}
		private function addView():void
		{
			_fileListView=new FileListView();
			_fileListView.x=750;
			_fileListView.y=50;
			addChild(_fileListView);
			ModelUiManege.fileListView=_fileListView;
			initData();
		}
		private function initData():void
		{
			stage.scaleMode=StageScaleMode.NO_SCALE
			stage.align=StageAlign.TOP_LEFT;
			stage.displayState == StageDisplayState.FULL_SCREEN
			Scene_data.stage=this.stage;
			Scene_data.root=this;
			initScene3D();
		}

		private function initScene3D():void
		{
			Scene_data.fileRoot="http://pan3dme.lt6.nns.cc/pan3D/yizhan/_File/nijia2/";
			Scene_data.fileRoot="../_File/beijing1/";
			Config.init(stage, _config_end);
		}

		private function _config_end():void
		{
			var context3D:Context3D=Scene_data.context3D;
			TextureManager.getInstance().init(context3D);
			MeshDataManager.getInstance().init(context3D);
			_sceneView=new BuildEditScene3D;
			_sceneView.initData();
			Scene_data.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
			Scene_data.stage.addEventListener(Event.RESIZE, stageResize)
			stage.scaleMode=StageScaleMode.NO_SCALE
			stage.align=StageAlign.TOP_LEFT;
			stageResize(new Event(Event.RESIZE))
			EditManage.makeBuildEidtChooseText();
			loadXmlData();

		}

		private function loadXmlData():void
		{
			//加载地面XML列表
			var _loaderURL:URLRequest=new URLRequest(Scene_data.fileRoot + "build/buildeditstatList.xml");
			var _scenexml:URLLoader=new URLLoader();
			_scenexml.load(_loaderURL);
			_scenexml.addEventListener(Event.COMPLETE, _loadGroundXmlOk);
			function _loadGroundXmlOk(event:Event):void
			{
				_fileListView.upDataXml(XML(_scenexml.data));
			}
		}
		protected function stageResize(event:Event):void
		{
			Scene_data.stageWidth=stage.stageWidth;
			Scene_data.stageHeight=stage.stageHeight;
			_sceneView.stageResize();
		}

		private function onEnterFrame(event:Event):void
		{
			_sceneView.upData();
		}

		public function get uiView():UiView
		{
			return null;
		}
	}
}
